import com.example.rpc.LoginProto.*;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

public class RpcClient {
    public static void main(String[] args) {
        ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080)
                .usePlaintext() // 在生产环境中使用 TLS
                .build();

        AuthServiceGrpc.AuthServiceBlockingStub stub = AuthServiceGrpc.newBlockingStub(channel);

        LoginRequest request = LoginRequest.newBuilder()
                .setUsername("user")
                .setPassword("pass")
                .build();

        LoginResponse response = stub.login(request);

        System.out.println("Response: " + response.getMessage());

        channel.shutdown();
    }
}